//
//  baseHttpClient.h
//  baseVC
//
//  Created by 陶磊 on 2019/12/16.
//  Copyright © 2019 QHT. All rights reserved.
//

//#import <Foundation/Foundation.h>
#import <AFNetworking.h>
#import <Foundation/Foundation.h>
#import "baseURLConfig.h"


//重定义block
typedef void (^requestBlock)(id data, long code, NSString *msgString);//请求回调
//typedef void (^requestFailureBlock)(id data, long code, NSString *msgString);//失败


NS_ASSUME_NONNULL_BEGIN

@interface baseHttpClient : NSObject

@property (nonatomic, strong) AFHTTPSessionManager *AFNHttpManager; //HTTP的管理对象指针

/**
 获取CLCWHttpClient对象的单例指针
 */
+ (baseHttpClient*) getInstance;


/**
 以POST方式创建、运行一个NSURLSessionDataTask对象
 
 @param URLString：请求的URL地址；
 @param parameters：请求参数字典；
 @param isNeedlogin：是否需要登录；
 @param success：POST任务运行成功后调用的块方法，没有返回类型，输入参数是id data【返回数据】,long code【返回码】,NSString *msgString【返回提示信息】；
 @param failure：POST运行任务失败后调用的块方法，没有返回类型，输入参数是id data【返回数据】,long code【返回码】,NSString *msgString【返回提示信息】；

 */

- (NSURLSessionDataTask *)POST:(NSString *)URLString
                    parameters:(id)parameters
                   isNeedlogin:(BOOL)isNeedlogin
                       success:(requestBlock)success
                       failure:(requestBlock)failure;

/** 便利构造器 */
+ (NSURLSessionDataTask *) requestPOST:(NSString *)URLString
                            parameters:(id)parameters
                           isNeedlogin:(BOOL)isNeedlogin
                               success:(requestBlock)success
                               failure:(requestBlock)failure;

/**
 以GET方式创建、运行一个NSURLSessionDataTask对象
 
 @param URLString：请求的URL地址；
 @param parameters：请求参数字典；
 @param success：GET任务运行成功后调用的块方法，没有返回类型，输入参数是id data【返回数据】,long code【返回码】,NSString *msgString【返回提示信息】；
 @param failure：GET运行任务失败后调用的块方法，没有返回类型，输入参数是id data【返回数据】,long code【返回码】,NSString *msgString【返回提示信息】；
 
 */
- (NSURLSessionDataTask *) GET:(NSString *)URLString
                    parameters:(id)parameters
                       success:(requestBlock)success
                       failure:(requestBlock)failure;

/** 便利构造器 */
+ (NSURLSessionDataTask *) requestGet:(NSString *)URLString
                            parameters:(id)parameters
                               success:(requestBlock)success
                               failure:(requestBlock)failure;


//文件下载
- (NSURLSessionDataTask *)DownloadFile:(NSString *)URLString
                               success:(requestBlock)success
                               failure:(requestBlock)failure;

//文件下载 类方法
+ (NSURLSessionDataTask *)DownloadFile:(NSString *)URLString
                               success:(requestBlock)success
                               failure:(requestBlock)failure;

#pragma mark -- 盘点 下载方法
//文件下载
- (NSURLSessionDataTask *)downloadFile:(NSString *)URLString
                               success:(requestBlock)success
                               failure:(requestBlock)failure;

//文件下载 类方法
+ (NSURLSessionDataTask *)downloadFile:(NSString *)URLString
                               success:(requestBlock)success
                               failure:(requestBlock)failure;


/** 便利构造器 */
+ (NSURLSessionDataTask *) requestHEAD:(NSString *)URLString
                            parameters:(id)parameters
                               success:(requestBlock)success
                               failure:(requestBlock)failure;



#pragma  上传 文件 图片
//上传单张图片
+ (void)uploadWithURLString:(NSString *)URLString
                 parameters:(id)parameters
                 uploadData:(NSData *)uploadData
                 uploadName:(NSString *)uploadName
                   fileName:(NSString *)fileName
                contentType:(NSString *)contentType
                    success:(requestBlock)success
                    failure:(requestBlock)failure;



// 上传多张图片
+ (void)uploadMostImageWithURLString:(NSString *)URLString
                          parameters:(id)parameters
                         uploadDatas:(NSArray *)uploadDatas
                          uploadName:(NSString *)uploadName
                            fileName:(NSString *)fileName
                         contentType:(NSString *)contentType
                             success:(void (^)(id responseObject))success
                             failure:(void (^)(NSError *error))failure;

//获取碎片 更新本地缓存库
+ (void) updateChipConfig;

/*
 源生请求
 
+ (nullable NSURLSessionDataTask *)requestWithNativeMethod:(HTTPMethod)method
                                              url:(NSString *)URLString
                                       parameters:(id)parameters
                                         progress:(void (^)(NSProgress * _Nonnull))uploadProgress
                                          success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
                                          failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure;
*/




@end

NS_ASSUME_NONNULL_END
